package com.csc531.views;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.csc531.DataTypes.Note;



/**
 * @author Javier Figueroa
 * View for the Notes in the NotesThinList class
 *
 */
public class NotesView extends LinearLayout 
{
	public NotesView(Context context, Note note, boolean expanded) 
	{
        super(context);

        this.setOrientation(VERTICAL);

        // Here we build the child views in code. They could also have
        // been specified in an XML file.

        mTitle = new TextView(context);
        mTitle.setText(note.getTitle());
        addView(mTitle, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

        mDescription = new TextView(context);
        mDescription.setText(note.getBody());
        addView(mDescription, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

        mDescription.setVisibility(expanded ? VISIBLE : GONE);
    }

    /**
     * Convenience method to set the title of a NotesView
     */
    public void setTitle(Note note)
    {
        mTitle.setText(note.getTitle());
    }

    /**
     * Convenience method to set the description of a NotesView
     */
    public void setDialogue(Note note) 
    {
        mDescription.setText(note.getBody());
    }

    /**
     * Convenience method to expand or hide the description
     */
    public void setExpanded(boolean expanded) 
    {
        mDescription.setVisibility(expanded ? VISIBLE : GONE);
    }

    private TextView mTitle;
    private TextView mDescription;
    public int id = 0;
}

